<?php
require_once('includes/config.php');
require_once('includes/sessions.php');

$stat = $db -> Execute("SELECT page FROM players WHERE email='".$_SESSION['email']."'");
if ($stat -> fields['miejsce'] != 'Chat') 
{
$db -> Execute("UPDATE players SET page='Chat' WHERE email='".$_SESSION['email']."'");
}
$stat -> Close();

$chat = $db -> SelectLimit("SELECT chat, user, czas, senderid FROM chat WHERE lokacja='Clima' ORDER BY id DESC", 25);
$e = $chat -> RecordCount();

$arrtext = array();
$arrauthor = array();
$arrsenderid = array();
$arrczas = array();
$i = $e-1;
while (!$chat -> EOF) 
{
    $text = wordwrap($chat -> fields['chat'],50,"\n",1);
	$arrtext[$i] = $text;
	$arrauthor[$i] = $chat -> fields['user'];
	$arrczas[$i] = $chat -> fields['czas'];
	$arrsenderid[$i] = $chat -> fields['senderid'];
	$chat -> MoveNext();
	$i = $i - 1;
}
$chat -> Close();
$d = 0;
while ($d < $e)
{
	echo $arrczas[$d].' <b>'.$arrauthor[$d].'</b>: '.$arrtext[$d].'<br>';
	$d = $d + 1;
}


?>
